/*
 * Copyright   2000   The Regents of the University of California
 * All Rights Reserved
 * 
 * Permission to use, copy, modify and distribute any part of Simgrid/SG
 * for educational, research and non-profit purposes, without fee, and
 * without a written agreement is hereby granted, provided that the above
 * copyright notice, this paragraph and the following three paragraphs
 * appear in all copies.
 * 
 * Those desiring to incorporate this Simgrid/SG into commercial
 * products or use for commercial purposes should contact the Technology
 * Transfer & Intellectual Property Services, University of California,
 * San Diego, 9500 Gilman Drive, Mail Code 0910, La Jolla, CA 92093-0910,
 * Ph: (858) 534-5815, FAX: (858) 534-7345, E-MAIL:invent@ucsd.edu.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
 * INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS Simgrid/SG,
 * EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.  
 * 
 * THE Simgrid/SG PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND THE
 * UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
 * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.  THE UNIVERSITY OF
 * CALIFORNIA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY
 * KIND, EITHER IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
 * PURPOSE, OR THAT THE USE OF THE Simgrid/SG WILL NOT INFRINGE ANY
 * PATENT, TRADEMARK OR OTHER RIGHTS.
 */

#ifndef SG_TYPES_H
#define SG_TYPES_H

#include "tbx_hashtable.h"
#include "simgrid_config.h"


/* SG_levelmode_t */
typedef enum {
  SG_SINGLE_LEVEL = 0,
  SG_MULTI_LEVEL
} SG_levelmode_t;

/* SG_taskstate_t */
/** \ingroup sg_types
 * \brief Specifies the state of a #SG_Task.
 */
typedef enum {
  SG_NOT_SCHEDULED = 0, /**< Not scheduled */
  SG_SCHEDULED, /**< Scheduled on a resource, but not ready for execution because of dependencies */
  SG_READY, /**< Scheduled and ready for execution */
  SG_RUNNING, /**< Running */
  SG_FAILED, /**< Task Failure */
  SG_DONE /**< Completed */
} SG_taskstate_t;

/* SG_failure_t */
/** \ingroup sg_types
 * \brief Specifies the type of a #SG_Resource
 */
typedef enum {
  SG_FAILURE_1 = 0, /**< A dummy variable for type of failure */
  SG_FAILURE_2, /**< A second dummy variable  */
  SG_FAILURE_3  /**< A third dummy variable */
} SG_failure_t;

/* SG_resource_t */
/** \ingroup sg_types
 * \brief Specifies the type of a #SG_Resource
 */
typedef enum {
  SG_LINK = 0, /**< A single network link (non TCP) */
  SG_HOST, /**< A host */
  SG_ROUTE /**< A TCP route link */
} SG_resource_t;

/* SG_task_t */
/** \ingroup sg_types
 * \brief Specifies the type of a #SG_Task.
 */
typedef enum {
  SG_TRANSFER = 0, /**< A data transfer */
  SG_COMPUTATION   /**< A computation   */
} SG_task_t;

/* SG_resourcesharing_t */
/** \ingroup sg_types
 * \brief Specifies the policy for sharing a (compute) #SG_Resource. 
 */
typedef enum {
  SG_SEQUENTIAL_IN_ORDER = 0, /**< Tasks are processed in a FIFO manner */
  SG_SEQUENTIAL_OUT_OF_ORDER, /**< Like the FIFO, but #SG_READY tasks can jump in front of #SG_SCHEDULED tasks */
  SG_TIME_SLICED, /**< All #SG_RUNNING tasks share the resource simulataneously
		       according to their priority */
  SG_FAT_PIPE, /**< Each #SG_RUNNING task runs as if it were alone on the resource (only for links) */
  SG_TCP /**< Only for #SG_LINK. Sharing according to the TCP protocol */
} SG_resourcesharing_t;

/* SG_global_sharing_policy_t */
typedef enum {
  SG_UNDEFINED=0,
  SG_NON_TCP_POLICY,
  SG_TCP_POLICY
} SG_global_sharing_policy_t;

/*
 * TCP sharing policies are represented by floating 
 * point values, so that we could enhance our model
 * to non-integer values (alpha-paramater)
 */

#define SG_TCP_BACKBONE 0.0
#define SG_TCP_SHARED 1.0


/* SG_outputmode_t */
/** \ingroup sg_types
 * \brief Specifies how much output SG sends to <b>stderr</b>
 */
typedef enum {
  SG_SILENT = 0, /**< No SG output is printed out  */
  SG_SOME,       /**< Some SG output is printed out */
  SG_VERBOSE     /**< Verbose SG output is printed out */
} SG_outputmode_t;

/* SG_trace_t */
typedef enum {
  SG_FIXED = 0,
  SG_DYNAMIC
} SG_trace_t;

/* SG_prediction_t */
/** \ingroup sg_types
 * \brief Specifies the type of a prediction
 */
typedef enum {
  SG_CUSTOM = 0, /**< The prediction error is specified by a user-defined function */
  SG_PERFECT, /**< The prediction error is 0 */
  SG_UNIFORM_AROUND, /**< The prediction error is uniformly distributed and symetric around 0 */
  SG_INITIAL /**< The prediction is based solely on the first value of the trace (with offset) */
} SG_prediction_t;


/* SG_Resource */
/** 
 * \ingroup sg_types
 *
 * \brief SG Resource abstraction
 *
 * A \a SG_Resource is either a network link, a TCP route, or a host. The
 * type is set at creation time, by calling #SG_newLink() or #SG_newTCPLink(),
 * #SG_newTCPRoute(), #SG_newHost(). 
 * The type value (#SG_resource_t) may be retrieved by 
 * calling #SG_getResourceType().
 */
typedef struct _SG_Resource *SG_Resource;

/* SG_Task */
/** 
 * \ingroup sg_types
 *
 * \brief SG Task abstraction
 *
 * A \a SG_Task is either a file transfer or a computation. The type is 
 * denoted by a #SG_task_t values which must be passed to #SG_newTask(). 
 * This value may be retrieved by calling #SG_getTaskType().
 */
typedef struct _SG_Task *SG_Task;

/* SG_EndToEndTransfer */
/** \ingroup sg_types
 * \brief SG End-to-end transfer abstraction
 *
 * A \a SG_EndToEndTransfer is a file transfer that takes place
 * over multiple consecutive links (non-TCP links) and that uses
 * message packetization. 
 */
typedef struct _SG_EndToEndTransfer *SG_EndToEndTransfer;

/* SG_Trace */
typedef struct _SG_Trace *SG_Trace;

/* SG_Prediction */
typedef struct _SG_Prediction *SG_Prediction;

/* SG_TimeSeries */
typedef struct _SG_TimeSeries *SG_TimeSeries;

/* Lists */
typedef TBX_HashTable_t SG_PredictionList;
typedef TBX_HashTable_t SG_TaskList;
typedef TBX_HashTable_t SG_ResourceList;
typedef TBX_HashTable_t SG_TraceList;

#endif				/* SG_TYPES_H */
